<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 添加/修改管理员信息</h3>
        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb"><i class="fa fa-angle-right"></i> 管理员信息
                        <a class="btn btn-theme btn-default" href="{:U('index')}">返回</a>
                    </h4>
                    <form id="admin" class="form-horizontal style-form" method="post" action="{:U('add')}"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员分类</label>
                            <div class="col-sm-10">
                                <select <if condition="$list.type eq 3"> disabled</if> id="type" name="type" class="form-control">
                                    <option value="1" <if condition="$list['type'] == 1">selected </if>>普通管理员</option>
                                    <option value="2" <if condition="$list['type'] == 2">selected</if>>超级管理员</option>
                                    <!--<option value="3" <if condition="$list['type'] == 3">selected</if>>商家</option>-->
                                </select>
                            </div>
                        </div>
                       <!-- <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员分配订单状态</label>
                            <div class="col-sm-10">
                                <select  name="gong" class="form-control">
                                <option value="1" <if condition="$list['gong'] == 1">selected </if>>可分配订单</option>
                                <option value="2" <if condition="$list['gong'] == 2">selected</if>>不可分配订单</option>
                                </select>
                            </div>
                        </div>-->
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员头像</label>
                            <div class="col-sm-10">
                                <input type="file" name="one" id="avatar" onchange='PreviewImage(this)' style="opacity: 0;display: block;cursor:pointer" />
                                <if condition="$list.img != NULL">
                                    <img class="ph-user"  src="{$list.img}" width="80" height="60" onclick="openFile()" style="cursor:pointer">
                                    <else/>
                                    <img class="ph-user" src="__PUBLIC__/img/wutu.png" alt="" width="80" height="80" onclick="openFile()" style="cursor:pointer">
                                </if>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员姓名</label>
                            <div class="col-sm-10">
                                <input id="name" name="name" value="{$list.name}" type="text"  class="form-control" placeholder="请输入管理员姓名/昵称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员账号</label>
                            <div class="col-sm-10">
                                <input id="numbers" name="numbers" value="{$list.numbers}" type="text"  class="form-control" placeholder="请输入管理员账号（最好为手机号）"><span id="info" style="float: left"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员密码</label>
                            <div class="col-sm-10">
                                <input id="password" name="password" value="{$list.password}" type="password"  class="form-control" placeholder="请输入管理员密码">
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">管理员邮箱</label>
                            <div class="col-sm-10">
                                <input id="email" name="email" value="{$list.email}" type="text"  class="form-control" placeholder="请输入管理员邮箱（需要分配技师工作的管理员可以添加邮箱）">
                            </div>
                        </div>-->
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">电话</label>
                            <div class="col-sm-10">
                                <input id="" name="phone" value="{$list.phone}" type="text"  class="form-control" placeholder="请输入管理员电话">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">禁用管理员</label>
                            <div class="col-sm-10">
                                <input id="status" name="status" value="2" type="checkbox" <if condition="$list['status'] == 2">checked</if> style="width: 20px;height: 20px"  />（勾选后该管理员将无法登录使用后台）
                            </div>
                        </div>
                        <input type="hidden" id="che" name="id" value="{$list.id}">
                        <input type="hidden" name="img" value="{$list.img}">
                        <input type="hidden" name="ps" value="{$list.password}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <input  type="button" id="tianjia" class="btn btn-theme" value="保存" style="width: 150px;margin-left: 60px">
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script>
   $("#type").change(function () {
       var type = $("#type").val();
       if(type == 3){
           $("#store").show();
       }else{
           $("#store").hide();
       }
   })
    $("#tianjia").click(function(){
        var che      = document.getElementById("che").value;
        var name     = document.getElementById("name").value;
        var numbers  = document.getElementById("numbers").value;
        var password = document.getElementById("password").value;
        var type     = $("#type").val();
        var store_id = $("#store_id").val();
        _store_id = false;
        if(type == 3 && store_id > 0){
            _store_id = true;
        }
        if(type < 3){
            _store_id = true;
        }
        if(_store_id == true){
            $.ajax({
                type:"post",
                data:{name:name,numbers:numbers,password:password,che:che},
                url:"{:U('checks')}",
                success:function (res) {
                    if(res.status == 1){
                        layer.open({
                            title: '管理员添加/修改提示：',content: res.info
                        });
                    }
                    if(res.status == 2){
                        document.getElementById("admin").submit();
                    }
                }
            })
        }else{
            layer.open({
                title: '管理员添加/修改提示：',content: "请选择店铺！"
            });
        }

    });
    //图片上传
    function openFile(){
        return  $("#avatar").click();
    }
    function PreviewImage(imgFile) {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        var o=imgFile.files[0];
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp'))
        {

            imgFile.focus();
        }else if(o.size > 2097152){
            imgFile.focus();
        }
        else
        {
            var path;
            path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
            $('.ph-user').attr({src:path});
        }
    }
</script>

</body>
</html>
